#ifndef EXTRACTPAGE_H
#define EXTRACTPAGE_H

#include <QWidget>
#include <QFileSystemModel>
#include "../core/codeprocessor.h"
#include "../core/wordexporter.h"
#include <QThread>
#include "../core/extractworker.h"
#include "customproxymodel.h"

namespace Ui {
class ExtractPage;
}

class ExtractPage : public QWidget
{
    Q_OBJECT

public:
    explicit ExtractPage(QWidget *parent = nullptr);
    ~ExtractPage();

private slots:
    void onBrowseButtonClicked();
    void onFileSelected(const QModelIndex &index);
    void onLanguageSelectionChanged(const QItemSelection &selected, const QItemSelection &deselected);
    void onSizeFilterChanged(const QString &sizeRange);
    void onExtractButtonClicked();

private:
    Ui::ExtractPage *ui;
    QFileSystemModel *fileModel;
    CustomProxyModel *proxyModel;
    QThread *workerThread;
    ExtractWorker *worker;
    
    void setupUI();
    void createConnections();
    void loadFile(const QString &filePath);
    bool filterFile(const QFileInfo &fileInfo);
    void collectFiles(const QString &path, const QString &language, QStringList &processedCode);
    int countFiles(const QString &path, const QString &language);
    QStringList getSelectedLanguages() const;
    void updateFileFilter();
};

#endif // EXTRACTPAGE_H 